package com.bluedog.listenter;

import com.bluedog.util.ColorUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.SignChangeEvent;

import java.util.List;

public class SignChangeListener implements Listener {

    @EventHandler
    public void onSignChange(SignChangeEvent event) {
        List<Component> lines = event.lines();
        for (int i = 0; i < lines.size(); i++) {
            TextComponent line = (TextComponent)lines.get(i);
            TextComponent.Builder lineText = ColorUtils.getTextBuilderWithColors(line.content());
            event.line(i,lineText.build());
        }
    }
}
